package com.hzdl.car.controller;

import com.github.pagehelper.PageInfo;
import com.hzdl.car.bean.Log;
import com.hzdl.car.service.LogService;
import com.hzdl.car.util.HzdlResultJson;
import com.hzdl.car.util.ResultObj;
import com.hzdl.car.vo.LogVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RequestMapping("log")
@RestController
public class LogController {
    @Resource
    private LogService logService;
    @RequestMapping("findLog")
    public HzdlResultJson findLog(LogVo logVo){
        PageInfo<Log> pageInfo=logService.findLog(logVo);
        return HzdlResultJson.ok(pageInfo.getTotal(),pageInfo.getList());
    }
    @RequestMapping("delLog")
    public ResultObj delLog(LogVo logVo){
        try {
            logService.dekLog(logVo);
            return ResultObj.DELETE_SUCCESS;

        }catch (Exception e){
            return  ResultObj.DELETE_ERROR;
        }
    }
    @RequestMapping("logDelChk")
    public ResultObj logDelChk(@RequestParam(value = "ids[]") Integer[] ids){
        try {
            logService.logDelChk(ids);
            return ResultObj.DELETE_SUCCESS;
        }catch (Exception e){
            return ResultObj.DELETE_ERROR;
        }
    }

}
